* installed packaged: grstyle, coefplot, grc1leg2 (not from ssc), ebalance

*********************************************************************
* Disentangling the Relationship Between Prospective Expectations   *
* and Policy Preferences in Violent Conflicts                       *
* Alon Yakter and Liran Harsgor 									*
* British Journal of Political Science (accepted 2025)				*
*                                                                   *
* Replication code - individual-level data analysis (cases)			*	 *********************************************************************
* The analysis was performed with Stata 17. 						*
* Users should install the following packages: estout, grystyle,	*
* ebalance, grc1leg2.												*
* (command line: "ssc install [package name], replace").			*
*																	*
* to load the data (the "use" command), users should place the .dta	*
* file in their Stata working directory (or type the full file 		*
* paths as saved on their computer).                      			*
*********************************************************************

*************************
* set up data as frames *
*************************
** reset data frames
frames reset
** 2006 data
use "Yakter & Harsgor BJPS 2025 - Hamas Election", replace
frame rename default hamas2006
** 1977 data
frame create sadat1977
frame change sadat1977
use "Yakter & Harsgor BJPS 2025 - Sadat Visit", replace
** 2006 aggregate data for expectation check
frame create hamas2006_shock
frame change hamas2006_shock
use "Yakter & Harsgor BJPS 2025 - Expectaion shock 2006", replace
** 1977 aggregate data for expectation check
frame create sadat1977_shock
frame change sadat1977_shock
use "Yakter & Harsgor BJPS 2025 - Expectaion shock 1977", replace
** 2006 data for longer plaecbo tests
frame create hamas2006_placebo
frame change hamas2006_placebo
use "Yakter & Harsgor BJPS 2025 - Placebo 2006", replace
** 1977 aggregate data for expectation check
frame create sadat1977_placebo
frame change sadat1977_placebo
use "Yakter & Harsgor BJPS 2025 - Placebo 1977", replace
** verify all frames loaded
frames dir

**********************
* set up graph style *
**********************
grstyle init
grstyle set plain, nogrid box
grstyle set compact
grstyle set legend, nobox klength(5)
grstyle set color black black


**************************************************
* Figure 3 - coefficient plots of primary models *
**************************************************
** 2006 data **
frame change hamas2006 
* quietly run models
qui reg support hamas_elec
estimates store full06noc
qui reg support hamas_elec female agegroup educ religiosity i.bloc
estimates store full06c
qui reg support hamas_elec female agegroup educ religiosity if bloc==1
estimates store left06
qui reg support hamas_elec female agegroup educ religiosity if bloc==3
estimates store right06
* coefficient plot (2006 panel)
coefplot full06noc ///
	(full06c, msymbol(D) msize(vlarge) color(gs9)  ///
		ciopts(lpattern(solid) lwidth(vthick) lcolor(gs9))) ///
	(left06, msymbol(S) msize(vlarge) color(maroon) mfcolor(white) ///
		ciopts(lpattern(solid) lwidth(vthick) lcolor(maroon%75))) ///
	(right06, msymbol(T) msize(vlarge) color(ebblue) mfcolor(white) ///
		ciopts(lpattern(solid) lwidth(vthick) lcolor(ebblue%75))) /// 
	, msize(vlarge) color(black) ///
		ciopts(lpattern(solid) lwidth(vthick) lcolor(black)) ///
	keep(hamas_elec) yline(0, lcolor(grey%30) lwidth(medthick)) vertical ///
	yscale(range(-0.2 0.2)) ///
	ylabel(-0.2 "-0.2" -0.1 "-0.1" 0 "0" 0.1 "0.1" 0.2 "0.2", nogrid labsize(medlarge)) ///
	xlabel(none) ytitle("Effect on Preferences (OLS Coefficient)", size(large)) ///
	legend(label(2 "Full Sample (No Controls)") label(4 "Full Sample (Controls)") ///
		label(6 "Left Voters Only") label(8 "Right Voters Only") ///
		size(large) rows(2)) ///
	title("A. Hamas's Electoral Victory (2006)", size(vlarge)) ///
	name(hamas, replace)
graph save hamas, replace
* Chi-square test for cross-model coefficient differences between right and left
qui suest left06 right06
test [left06_mean]hamas_elec = [right06_mean]hamas_elec

** 1977 data ** 
frame change sadat1977
* quietly run models
eststo clear
qui reg support visit
estimates store full77noc
qui reg support visit female educ agegroup religiosity i.bloc
estimates store full77c
qui reg support visit female educ agegroup religiosity if bloc==1
estimates store left77
qui reg support visit female educ agegroup religiosity if bloc==3
estimates store right77
* coefficient plot (1977 panel)
grstyle init
grstyle set legend, nobox
grstyle set plain, nogrid box
grstyle set compact
grstyle set legend, nobox klength(5)
grstyle set color black black
coefplot full77noc ///
	(full77c, msymbol(D) msize(vlarge) color(gs9) ///
		ciopts(lpattern(solid) lwidth(vthick) lcolor(gs9))) ///
	(left77, msymbol(S) msize(vlarge) color(maroon) mfcolor(white) ///
		ciopts(lpattern(solid) lwidth(vthick) lcolor(maroon%75))) ///
	(right77, msymbol(T) msize(vlarge) color(ebblue) mfcolor(white) ///
		ciopts(lpattern(solid) lwidth(vthick) lcolor(ebblue%75))) /// 
	, msize(vlarge) color(black) ///
		ciopts(lpattern(solid) lwidth(vthick) lcolor(black)) ///
	keep(visit) yline(0, lcolor(grey%30) lwidth(medthick)) vertical ///
	yscale(range(-0.2 0.2)) ///
	ylabel(-0.2 "-0.2" -0.1 "-0.1" 0 "0" 0.1 "0.1" 0.2 "0.2", nogrid labsize(medlarge)) ///
	xlabel(none) ytitle("Effect on Preferences (OLS Coefficient)", size(large)) ///
	legend(label(2 "Full Sample (No Controls)") label(4 "Full Sample (Controls)") ///
		label(6 "Left Voters Only") label(8 "Right Voters Only") ///
		size(large) rows(2)) ///
	title("B. Sadat's Visit (1977)", size(vlarge)) ///
	name(sadat, replace)
graph save sadat, replace
* Chi-square test for cross-model coefficient differences between right and left
qui suest left77 right77
test [left77_mean]visit = [right77_mean]visit

** combine coefficient plots to single graph **
graph use hamas
grc1leg2 hamas sadat, ///
	xsize(4.5) ysize(2) iscale(*1.15)

*************************************************
* Figure B3 - descriptive distribution and mean *
*************************************************
** 2006 data **
frame change hamas2006
* extract summary statistics for mean
qui reg support hamas_elec
sum support if e(sample)
* plot distribution (2006 panel)
grstyle init
grstyle set legend, nobox
grstyle set plain, nogrid box
graph bar (percent), ///
	over(support, gap(*0.5) relabel(1 "0" 2 "0.33" 3 "0.67" 4 "1")) ///
	bar(1 ,color(black)) ytitle("Percent", size(medlarge)) ///
	yscale(range(0(10)50)) ylabel(0 "0%" 10 "10%" 20 "20%" 30 "30%" 40 "40%" 50 "50%") ///	
	text(49 0.5 "Mean=0.65", place(e) size(medlarge)) ///
	text(46 0.5 "S.D.=0.37", place(e) size(medlarge)) ///
	title("2006 Data") name(dv2006, replace)

** 1977 data **
frame change sadat1977
* extract summary statistics
qui reg support visit 
sum support if e(sample)
* plot distribution (1977 panel)
grstyle init
grstyle set legend, nobox
grstyle set plain, nogrid box
graph bar (percent), ///
	over(support, gap(*0.5) relabel(1 "0" 2 "0.25" 3 "0.5" 4 "0.75" 5 "1")) ///
	bar(1 ,color(black)) ytitle("Percent", size(medlarge)) ///
	yscale(range(0(10)50)) ylabel(0 "0%" 10 "10%" 20 "20%" 30 "30%" 40 "40%" 50 "50%") ///	
	text(49 0.5 "Mean=0.40", place(e) size(medlarge)) ///
	text(46 0.5 "S.D.=0.22", place(e) size(medlarge)) ///
	title("1977 Data") name(dv1977, replace)
	
* combine descriptive plots to single graph *
graph combine dv2006 dv1977, ///
	xsize(4.7) ysize(2) iscale(*1.5)

*************************************************
* Table B3 - summary stats for other covariates *
*************************************************
* summary stats - 2006
frame change hamas2006
sum female educ agegroup religiosity i.bloc if hamas_elec!=.
* summary stats - 1977
frame change sadat1977
sum female educ agegroup religiosity i.bloc


*******************************	
* Figure B4 - treatment check *
*******************************	
** 2006 data **
frame change hamas2006_shock
* prep data for time series analysis
gen ts_date = ym(year,month)
order ts_date, after(month)
tsset ts_date, monthly
* combine categories
gen belief = strong_belief + mild_belief
gen disbelief = mild_disbelief + strong_disbelief
* plot shock
twoway (tsline belief, recast(connected) mcolor(navy) ///
		lpattern(solid) lwidth(medthin) lcolor(navy%70)) ///
	(tsline so_so, recast(connected) mcolor(black) msymbol(T) ///
		lwidth(thin) lcolor(black%40)) ///
	(tsline disbelief, recast(connected) mcolor(maroon) msymbol(Sh) ///
		lwidth(thin) lcolor(maroon%70)) ///
	,xline(551.5, lcolor(black%60) lpattern(dash))  ///
	yscale(range(5 65)) ylabel(10 "10%" 20 "20%" 30 "30%" 40 "40%" 50 "50%" 60 "60%") ///
	xlabel(549 "10/2005" 550 "11/2005" 551 "12/2005" 552 "1/2006" 553 "2/2006" 554 "3/2006") ///
	ytitle("Respondent Share") xtitle("Survey Month") ///
	legend(label(1 "Belief") label(2 "So-So") label(3 "Disbelief") rows(1)) ///
	scale(1.2)
	
** 1977 data **
frame change sadat1977_shock
* prep data for time series analysis
gen ts_date = mdy(month,day,year)
order ts_date, after(day)
tsset ts_date, daily
* combine categories
gen yes_short = yes_dys_wks + yes_1_2yrs
gen yes_long = yes_3_5yrs + yes_6_10yrs + yes_10yrs
gen yes = yes_dys_wks + yes_1_2yrs + yes_3_5yrs + yes_6_10yrs + yes_10yrs
* plot shock
twoway (tsline no, recast(connected) mcolor(navy) ///
		lpattern(solid) lwidth(medthin) lcolor(navy%70)) ///
	(tsline yes_long, recast(connected) mcolor(maroon) msymbol(Sh) ///
		lwidth(thin) lcolor(maroon%70)) ///
	(tsline yes_short, recast(connected) mcolor(cranberry) msymbol(T) ///
		lwidth(thin) lcolor(cranberry%70)) if month!=1 ///
	,xline(6530, lcolor(black%60) lpattern(dash))  ///
	yscale(range(5 65)) xscale(range(6482 6575))  ///
	ylabel(10 "10%" 20 "20%" 30 "30%" 40 "40%" 50 "50%" 60 "60%") ///
	xlabel(6482 "10/1977" 6513 "11/1977" 6544 "12/1977" 6575 "1/1978") ///
	ytitle("Respondent Share") xtitle("Survey Date") ///
	legend(label(1 "No") label(2 "Yes (3+ years)") label(3 "Yes (0-2 years)") rows(1)) ///
	scale(1.2)
	
****************************
* Table B4 - Balance tests *
****************************
** 2006 data **
frame change hamas2006
* generate categorical dummies for bloc
tab bloc, gen(bloc)
* balance table	
foreach var of varlist female agegroup educ religiosity bloc1 bloc2 bloc3 {
	dis "Variable `var':"
	ttest `var', by(hamas_elec)
}
drop bloc1-bloc3

** 1977 data **
frame change sadat1977
* generate categorical dummies for bloc
tab bloc, gen(bloc)
* balance table	
foreach var of varlist female agegroup educ religiosity bloc1 bloc2 bloc3 {
	dis "Variable `var':"
	ttest `var', by(visit)
}
drop bloc1-bloc3

****************************************
* Table B5 - full estimations for 2006 *
****************************************
frame change hamas2006
eststo clear 
qui eststo: reg support hamas_elec
qui eststo: reg support hamas_elec female agegroup educ religiosity i.bloc
qui eststo: reg support hamas_elec female agegroup educ religiosity if bloc==1
qui eststo: reg support hamas_elec female agegroup educ religiosity if bloc==3
esttab, b(3) se(3) r2(3) ///
	nogaps compress drop(1.bloc) ///
	coeflabels(hamas_elec "Hamas Election" female "Female" agegroup "Age Group"	educ "Education" ///
		religiosity "Religiosity" 2.bloc "Bloc: Center" 3.bloc "Bloc: Right" _cons "Constant") ///
	mtitles("No Controls" "Controls" "Left-wingers" "Right-wingers") ///
	addnotes("The baseline level for Bloc is left-wing vote.")

****************************************
* Table B6 - full estimations for 1977 *
****************************************
frame change sadat1977
eststo clear
qui eststo: reg support visit 
qui eststo: reg support visit female educ agegroup religiosity i.bloc
qui eststo: reg support visit female educ agegroup religiosity if bloc==1
qui eststo: reg support visit female educ agegroup religiosity if bloc==3
esttab, b(3) se(3) r2(3) ///
	nogaps compress drop(1.bloc) ///
	coeflabels(visit "Sadat's Visit" female "Female" agegroup "Age Group"	educ "Education" ///
		religiosity "Religiosity" 2.bloc "Bloc: Center" 3.bloc "Bloc: Right" _cons "Constant") ///
	mtitles("No Controls" "Controls" "Left-wingers" "Right-wingers") ///
	addnotes("The baseline level for Bloc is left-wing vote.")

********************************
* Table B7 - emtropy balancing *
********************************
** 2006 data ** 
frame change hamas2006
* create matching weights
ebalance hamas_elec female i.agegroup i.educ i.religiosity i.bloc, tar(2) gen(w_bloc)
ebalance hamas_elec female i.agegroup i.educ i.religiosity, tar(2) gen(w_nobloc)
* estimate bivariate regression with the weights
eststo clear
qui eststo: reg support hamas_elec [w=w_bloc]
qui eststo: reg support hamas_elec [w=w_nobloc] if bloc==1
qui eststo: reg support hamas_elec [w=w_nobloc] if bloc==3
esttab, b(3) se(3) r2(3) ///
	nogaps compress ///
	coeflabels(hamas_elec "Hamas Election" _cons "Constant") ///
	mtitles("Full Sample" "Left-wingers" "Right-wingers")

** 1977 data ** 
frame change sadat1977
* create matching weights
ebalance visit female i.agegroup i.educ i.religiosity i.bloc, tar(2) gen(w_bloc)
ebalance visit female i.agegroup i.educ i.religiosity, tar(2) gen(w_nobloc)
* estimate bivariate regression with the weights
eststo clear
qui eststo: reg support visit [w=w_bloc]
qui eststo: reg support visit [w=w_nobloc] if bloc==1
qui eststo: reg support visit [w=w_nobloc] if bloc==3
esttab, b(3) se(3) r2(3) ///
	nogaps compress ///
	coeflabels(visit "Sadat's Visit" _cons "Constant") ///
	mtitles("Full Sample" "Left-wingers" "Right-wingers")
	
****************************************
* Table B9 - nearest-neighbor matching *
****************************************
** 2006 data ** 
frame change hamas2006
* calculate ATE
teffects nnmatch (support female agegroup educ religiosity i.bloc) (hamas_elec), nn(2)
teffects nnmatch (support female agegroup educ religiosity) (hamas_elec) if bloc==1, nn(2)
teffects nnmatch (support female agegroup educ religiosity) (hamas_elec) if bloc==3, nn(2)
* claculate ATET
teffects nnmatch (support female agegroup educ religiosity i.bloc) (hamas_elec), nn(2) atet
teffects nnmatch (support female agegroup educ religiosity) (hamas_elec) if bloc==1, nn(2) atet
teffects nnmatch (support female agegroup educ religiosity) (hamas_elec) if bloc==3, nn(2) atet

** 1977 data ** 
frame change sadat1977
* calculate ATE
teffects nnmatch (support female agegroup educ religiosity i.bloc) (visit), nn(2)
teffects nnmatch (support female agegroup educ religiosity) (visit) if bloc==1, nn(2)
teffects nnmatch (support female agegroup educ religiosity) (visit) if bloc==3, nn(2)
* calculate ATET
teffects nnmatch (support female agegroup educ religiosity i.bloc) (visit), nn(2) atet
teffects nnmatch (support female agegroup educ religiosity) (visit) if bloc==1, nn(2) atet
teffects nnmatch (support female agegroup educ religiosity) (visit) if bloc==3, nn(2) atet

***********************************
* Figure B6 - narrower bandwidths *
***********************************
** 2006 data ** 
frame change hamas2006
* quietly run models
qui reg support hamas_elec
estimates store full06noc
qui reg support hamas_elec female agegroup educ religiosity i.bloc
estimates store full06c
qui reg support hamas_elec female agegroup educ religiosity if bloc==1
estimates store left06
qui reg support hamas_elec female agegroup educ religiosity if bloc==3
estimates store right06
qui eststo: reg support hamas_elec if (surveyid==200512 | surveyid==200602)
estimates store full06noc_1s
qui eststo: reg support hamas_elec female agegroup educ religiosity i.bloc if (surveyid==200512 | surveyid==200602)
estimates store full06c_1s
qui eststo: reg support hamas_elec female agegroup educ religiosity if bloc==1 & (surveyid==200512 | surveyid==200602)
estimates store left06_1s
qui eststo: reg support hamas_elec female agegroup educ religiosity if bloc==3 & (surveyid==200512 | surveyid==200602)
estimates store right06_1s
* coefficient plot (2006 panel)
grstyle init
grstyle set plain, nogrid box
grstyle set compact
grstyle set legend, nobox klength(5)
grstyle set color black black
coefplot full06noc ///
	(full06c_1s, msize(vlarge) color(black)  ///
		ciopts(lpattern(dash) lwidth(thick) lcolor(black))) ///
	(full06c, msymbol(D) msize(vlarge) color(gs9)  ///
		ciopts(lpattern(solid) lwidth(vthick) lcolor(gs9))) ///
	(full06c_1s, msymbol(D) msize(vlarge) color(gs9)  ///
		ciopts(lpattern(dash) lwidth(thick) lcolor(gs9))) ///
	(left06, msymbol(S) msize(vlarge) color(maroon) mfcolor(white) ///
		ciopts(lpattern(solid) lwidth(vthick) lcolor(maroon%75))) ///
	(left06_1s, msymbol(S) msize(vlarge) color(maroon) mfcolor(white) ///
		ciopts(lpattern(dash) lwidth(thick) lcolor(maroon%75))) ///
	(right06, msymbol(T) msize(vlarge) color(ebblue) mfcolor(white) ///
		ciopts(lpattern(solid) lwidth(vthick) lcolor(ebblue%75))) /// 
	(right06_1s, msymbol(T) msize(vlarge) color(ebblue) mfcolor(white) ///
		ciopts(lpattern(dash) lwidth(thick) lcolor(ebblue%75))) /// 
	, msize(vlarge) color(black) ///
		ciopts(lpattern(solid) lwidth(vthick) lcolor(black)) ///
	keep(hamas_elec) yline(0, lcolor(grey%30) lwidth(medthick)) vertical ///
	yscale(range(-0.2 0.2)) ///
	ylabel(-0.2 "-0.2" -0.1 "-0.1" 0 "0" 0.1 "0.1" 0.2 "0.2", nogrid labsize(medlarge)) ///
	xlabel(none) ytitle("Effect on Preferences (OLS Coefficient)", size(large)) ///
	legend(order(2 "Full Sample (No Controls)" 6 "Full Sample (Controls)" ///
		10 "Left Voters Only" 14 "Right Voters Only") ///
		size(large) rows(2)) ///
	title("A. Hamas's Electoral Victory (2006)", size(vlarge)) ///
	name(hamas_1s, replace)
graph save hamas_1s, replace

** 1977 data ** 
frame change sadat1977
* quietly run models
eststo clear
qui reg support visit
estimates store full77noc
qui reg support visit female educ agegroup religiosity i.bloc
estimates store full77c
qui reg support visit female educ agegroup religiosity if bloc==1
estimates store left77
qui reg support visit female educ agegroup religiosity if bloc==3
estimates store right77
qui reg support visit  if (surveyid==130| surveyid==134)
estimates store full77noc_1s
qui reg support visit female educ agegroup religiosity i.bloc if (surveyid==130| surveyid==134)
estimates store full77c_1s
qui reg support visit female educ agegroup religiosity if bloc==1 & (surveyid==130| surveyid==134)
estimates store left77_1s
qui reg support visit female educ agegroup religiosity if bloc==3 & (surveyid==130| surveyid==134)
estimates store right77_1s
* coefficient plot (1977 panel)
grstyle init
grstyle set legend, nobox
grstyle set plain, nogrid box
grstyle set compact
grstyle set legend, nobox klength(5)
grstyle set color black black
coefplot full77noc ///
	(full77c_1s, msize(vlarge) color(black)  ///
		ciopts(lpattern(dash) lwidth(thick) lcolor(black))) ///
	(full77c, msymbol(D) msize(vlarge) color(gs9)  ///
		ciopts(lpattern(solid) lwidth(vthick) lcolor(gs9))) ///
	(full77c_1s, msymbol(D) msize(vlarge) color(gs9)  ///
		ciopts(lpattern(dash) lwidth(thick) lcolor(gs9))) ///
	(left77, msymbol(S) msize(vlarge) color(maroon) mfcolor(white) ///
		ciopts(lpattern(solid) lwidth(vthick) lcolor(maroon%75))) ///
	(left77_1s, msymbol(S) msize(vlarge) color(maroon) mfcolor(white) ///
		ciopts(lpattern(dash) lwidth(thick) lcolor(maroon%75))) ///
	(right77, msymbol(T) msize(vlarge) color(ebblue) mfcolor(white) ///
		ciopts(lpattern(solid) lwidth(vthick) lcolor(ebblue%75))) /// 
	(right77_1s, msymbol(T) msize(vlarge) color(ebblue) mfcolor(white) ///
		ciopts(lpattern(dash) lwidth(thick) lcolor(ebblue%75))) /// 
	, msize(vlarge) color(black) ///
		ciopts(lpattern(solid) lwidth(vthick) lcolor(black)) ///
	keep(visit) yline(0, lcolor(grey%30) lwidth(medthick)) vertical ///
	yscale(range(-0.2 0.2)) ///
	ylabel(-0.2 "-0.2" -0.1 "-0.1" 0 "0" 0.1 "0.1" 0.2 "0.2", nogrid labsize(medlarge)) ///
	xlabel(none) ytitle("Effect on Preferences (OLS Coefficient)", size(large)) ///
	legend(order(2 "Full Sample (No Controls)" 6 "Full Sample (Controls)" ///
		10 "Left Voters Only" 14 "Right Voters Only") ///
		size(large) rows(2)) ///
	title("B. Sadat's Visit (1977)", size(vlarge)) ///
	name(sadat_1s, replace)
graph save sadat_1s, replace

** combine coefficient plots to single graph **
graph use hamas_1s
grc1leg2 hamas_1s sadat_1s, ///
	xsize(4.5) ysize(2) iscale(*1.15)

**********************************
* Table B10 - placebo tests 2006 *
**********************************
frame change hamas2006
* generate placebo within the pre-treatment group
gen placebo_pre = .
replace placebo_pre = 0 if surveyid==200511
replace placebo_pre = 1 if surveyid==200512
* run regression with pre-treatment placebo
eststo clear
qui eststo: reg support hamas_elec female agegroup educ religiosity i.bloc
qui eststo: reg support placebo_pre female agegroup educ religiosity i.bloc
* load data for one-year placebos
frame change hamas2006_placebo
* run regression for one-year placebos 
qui eststo: reg support placebo_year_pre female agegroup educ religiosity i.bloc
qui eststo: reg support placebo_year_post female agegroup educ religiosity i.bloc
* generate table
esttab, b(3) se(3) r2(3) ///
	nogaps compress drop(1.bloc) ///
	order(hamas_elec placebo_pre placebo_year_pre placebo_year_post) ///
	coeflabels(hamas_elec "Hamas Election" female "Female" agegroup "Age Group"	educ "Education" ///
		religiosity "Religiosity" 2.bloc "Bloc: Center" 3.bloc "Bloc: Right" _cons "Constant" ///
		placebo_pre "Within-control" placebo_year_pre "1 Year Prior" ///
		placebo_year_post "1 Year After") ///
	mtitles("Real Treatment" "Within-control" "1 Year Prior" "1 Year After") ///
	addnotes("The baseline level for Bloc is left-wing vote.")

*********************************
* Table B11 - placebo tests 1977 *
**********************************
frame change sadat1977
* generate placebo within the pre-treatment group
gen placebo_pre = .
replace placebo_pre = 0 if surveyid==129
replace placebo_pre = 1 if surveyid==130
* run regression with pre-treatment placebo
eststo clear 
qui eststo: reg support visit female educ agegroup religiosity i.bloc
qui eststo: reg support placebo_pre female educ agegroup religiosity i.bloc
* load data for 6-month/one-year placebo
frame change sadat1977_placebo
* run regression for 6-month/one-year placebo 
qui eststo: reg support placebo_6m_pre female agegroup educ religiosity i.bloc
qui eststo: reg support placebo_year_post female agegroup educ religiosity i.bloc
* generate table
esttab, b(3) se(3) r2(3) ///
	nogaps compress drop(1.bloc) ///
	order(visit placebo_pre placebo_6m_pre placebo_year_post) ///
	coeflabels(visit "Sadat's Visit" female "Female" agegroup "Age Group"	educ "Education" ///
		religiosity "Religiosity" 2.bloc "Bloc: Center" 3.bloc "Bloc: Right" _cons "Constant" ///
		placebo_pre "Within-control Placebo" placebo_6m_pre "6 Months Prior" ///
		placebo_year_post "1 Year After") ///
	mtitles("Real Treatment" "Within-control" "6 Months Prior" "1 Year After") ///
	addnotes("The baseline level for Bloc is left-wing vote.")
